Hi all, I have written a script in which i need to update the user information from a csv file. Can you please let me know whats wrong with this program? as i am neither getting any error nor the user values are updated. Please find the attachments for more details. Here is the code :
pragma runLim,0
string filename = "C:\\Users\\Downloads\\Book1.csv"
string filename2= "C:\\Users\\Downloads\\output.txt"
Skip split_string (string str)
{
Skip skp2 = create
int cnt = 0
int prev_cnt = 0
int ind1 = 0
for (cnt1=0; cnt1<length(str); cnt1++)
{
if (str[cnt1:cnt1] == ",")
{
put(skp2,ind1,str[prev_cnt:cnt1-1])
prev_cnt = cnt1+1
ind1++
}
}
return skp2
}
Stream input = read filename
Stream output = write filename2
string str=""
string str1="",fullName= "", email="", telephone=""
input >> str
while (! end(input))
{
str = ""
str1=""
fullName=""
email=""
telephone=""
input >> str
//print str "\n"
Skip usr_skp = split_string(str)
find (usr_skp, 0, str1)
find (usr_skp, 1, fullName)
output<<str1 "\t"
if (str1 == "") {
output << "###user id in the input excel is empty###\n"
if (end input) break
else continue
}
find (usr_skp, 2, email)
find (usr_skp, 3, telephone)
User u
for u in userList do {
loadUserRecord(u)
string id= u.name
if(id==str1)
u.fullName=fullName
u.email=email
u.telephone=telephone
saveUserRecord (u)
saveDirectory()
}
output << "The user details were updated" "\n"
delete usr_skp
}
close (input)
close (output)
and the content of the csv is as this
name,fullName,email,telephone,
Please let me know whats wrong with this code.. thanks in advance for your help!!
doors@36677 - Tue Jul 19 04:18:12 EDT 2016 |
Re: User information not getting updated in the directory ok found a way now.....!!! its working :) |